@include('admin.public.head')

<div class="ibox-title">
    <h5>積分操作</h5>
</div>

<div class="ibox-content">
    <form  class="form-horizontal">

        <div class="form-group">
            <label class="col-sm-3 control-label">操作積分：</label>
            <div class="col-sm-3">
                <input type="text" name="integral" class="form-control" placeholder="操作積分" value="">
            </div>
        </div>
        <div class="hr-line-dashed"></div>

        <div class="form-group">
            <label class="col-sm-3 control-label">備注：</label>
            <div class="col-sm-3">
                <input type="text" name="reason" class="form-control" placeholder="備注" value="">
            </div>
        </div>
        <div class="hr-line-dashed"></div>

        <label class="col-sm-3 control-label">單選框：</label>
        <div class="col-sm-9">
            <label class="radio-inline">
                <input type="radio" checked=""  name="type" value="1">客服加分</label>
            <label class="radio-inline">
                <input type="radio"   name="type" value="5">客服扣分</label>
        </div>

        <input type="hidden" name="id" value="{{$id??0}}">

        <div class="form-group">
            <div class="col-sm-4 col-sm-offset-3">
                <a class="btn btn-primary do" type="submit">操作</a>
            </div>
        </div>
    </form>
</div>
<script>
    $('.do').click(function(){
        var form = new FormData();

        var integral = $('input[name="integral"]').val();
        var reason = $('input[name="reason"]').val();
        var type = $("input[name='type']:checked").val();

        var id = $('input[name="id"]').val();

        form.append("reason", reason);
        form.append("integral", integral);
        form.append("type", type);
        form.append("id", id);

        $.ajax({
            type: 'POST',
            url: '/record_do' ,
            dataType:"json",   //返回格式为json
            data: form ,
            processData: false,
            contentType: false,
            success:function(data){

                if(data.status == '1') {
                    var swal_json = {
                        title: data.message,
                        type: "success"
                    }

                    swal(swal_json, function (isConfirm) {
                        //window.location.reload();
                    });

                }else{
                    var swal_json = {
                        title: data.message,
                        type: "error"
                    }

                    swal(swal_json, function (isConfirm) {

                    });
                }
            }
        });

        return false;
    });
</script>
